package net.learn.piggy.bean;

import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

@Component
public class Bean implements InitializingBean, DisposableBean {

    private ExecutorService executorService;
    public ExecutorService getExecutorService() {
        return executorService;
    }
    @Override
    public void afterPropertiesSet() {
        executorService = Executors.newCachedThreadPool();
        System.out.println("Bean --> afterPropertiesSet");
    }
    @Override
    public void destroy() {
        executorService.shutdown();
        System.out.println("Bean --> destroy");
    }

}
